/**
 * 
 */

package timer;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * WebApplicationContext 實作了 ApplicationContext 介面，是 Spring 專為 Servlet 的 Web 應用程式設計的 ApplicationContext 實作類別，<br>
 * 在取得 WebApplicationContext 之後，您可以利用它來取得 Bean 定義檔中定義的 Bean 實例，例如：Date date = (Date) ctx.getBean("dateBean");
 * 
 * @author Eric.Kao(gau168.gau@msa.hinet.net)
 * @version 1.0
 * @company E885 Group
 * @copyright Copyright (c) 2001-2008
 */

public class TimerServlet extends HttpServlet
{
	private static final long serialVersionUID = -4470586600580114997L;

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
	{
		WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext( getServletContext() );

		PrintWriter out = resp.getWriter();

		out.println( ctx.getBean( "dateBean" ) );
	}

}
